< previous page page_603 next page >

Page 603
Dim sAttrib As String
    Dim sDriver As String

    sAttrib = "DBQ=D:\VB5\BIBLIO.mdb"
    sDriver = "Microsoft Access Driver (*.mdb)"
  DBEngine.RegisterDatabase "MyDSN", sDriver, True, sAttrib
After executing the preceding code, you can go back to the Data Source Administrator window and verify that a new User DSN has been added.
note.gif You can also use the rdoRegisterDataSource method of the rdoEngine to perform the registration task for Remote Data Objects. square.gif

Notice that, for the Access driver, the DBQ parameter indicates the name of the database file. To determine all the parameters required for a particular ODBC driver, you should create a connection with the ODBC Manager and then examine the settings in the Registry. You can find these under HKEY_USERS\Default\Software\ODBC\ODBC.INI. (To view the Registry, use Windows' REGEDIT utility.) To specify multiple parameters with the RegisterDatabase method, separate them with a semicolon.
The Remote Data Objects
Data access objects (DAO) are a layer on top of the ODBC API. Before the advent of Remote Data Objects (RDO) in Visual Basic, programmers would sometimes skip this layer by calling the ODBC API directly. The reason, of course, was to make their applications run faster. However, the ODBC API calls are much harder to use than the Data Access Objects. Remote data objects changed this by providing an interface to the ODBC API that uses the familiar operations of setting properties and calling methods. Because properties and methods are used in all Visual Basic programs, this made the access of ODBC databases much easier for developers to understand and accomplish.
Comparison of RDO to DAO
The remote data objects, or RDO, are very similar to the data access objects (DAO), which were covered in Chapter 26, "Using Data Access Objects (DAO)." This similarity not only makes RDO easier to understand, but it also makes the conversion of programs from PC databases to client/server databases much easier. In fact, after the connection to the data source is made, the same code statements that were used for DAO can be used to access the data using RDO. To give you a feel for the similarities between the RDO and DAO models, Table 27.2 lists a number of RDO objects and their corresponding DAO objects.
In addition, the rdoResultset object supports several types of returned sets of records, similar to the recordset types of the Recordset object. Table 27.3 summarizes these similarities.

 
< previous page page_603 next page >